package demo3;

import java.io.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Author:  LiuTao
 * Version: 1.0
 * Date:    2023-11-09  09:20
 */
public class Test1 {
    public static void main(String[] args) throws IOException {
        String name;
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        FileWriter fw = new FileWriter("name.txt");
        BufferedWriter bw = new BufferedWriter(fw);
        while (true) {
            System.out.println("请输入姓名：");
            name = br.readLine();
            if (name.equals("")) {
                break;
            }
            bw.write(name);
            bw.newLine();
        }
        br.close();
        bw.close();
        System.out.println("姓名已保存到name.txt文件中。");
    }
}
